// 支持切换的主题值
export type ThemeType = "dark" | "light"
// 配置主题对象
const themes = {
  dark: {
    bgColor: "#000",
    textColor: "#fff"
  },
  light: {
    bgColor: "#fff",
    textColor: "#000"
  }
}
// 保存主题色
export const saveLocalStorage = (theme: ThemeType) => {
  localStorage.setItem("theme", theme)
}
// 获取存储的主题色
export const getLocalStorageThem = (): ThemeType => {
  return localStorage.getItem("theme") as ThemeType || "light"
}
// 切换主题色的方法
export const changeTheme = (theme: ThemeType) => {
  const config = themes[theme]
  const root = document.documentElement
  root.style.setProperty("--bg--color", config.bgColor)
  root.style.setProperty("--text--color", config.textColor)
}